<template>
  <div class="app-container">
    <el-form :inline="true" :model="listQuery" @submit.native.prevent>
      <el-form-item label="日期">
        <el-date-picker
          v-model="listQuery.yxkjdate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="商家">
        <el-select
          class="toolbar-lable-right"
          size="small"
          v-model="listQuery.q_sellerId"
          placeholder="请选择"
        >
          <el-option
            v-for="item in optStateValues"
            :key="item.id"
            :label="item.sellerName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="this.getList">查询</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      ref="singleTable"
      :data="dataList"
      v-loading="listLoading"
      border
      fit
      highlight-current-row
      tooltip-effect="dark"
      style="width: 100%"
    >
      <el-table-column type="index" align="center" width="50"> </el-table-column>
      <el-table-column width="160" property="orderDay" label="日期"> </el-table-column>
      <el-table-column width="400" show-overflow-tooltip property="productName" label="商品名称"> </el-table-column>
      <el-table-column property="sellerName" label="店铺名称"> </el-table-column>
      <el-table-column property="moneyAmount" label="金额"> </el-table-column>
      <el-table-column property="number" label="数量"> </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { getSellers } from "@/api/all";
import { fetchProductDayList } from "@/api/report";
import Pagination from "@/components/Pagination";
export default {
  name: 'reportorderday',
  components: { Pagination },
  data() {
    return {
      dataList: [],
      optStateValues: [],
      total: 0,
      listLoading: false,
      listQuery: {
        page: 1,
        limit: 20,
        yxkjdate: '',
        q_sellerId: ""
      },
    }
  },
  created() {
    this.getList();
    getSellers().then(res=>{
      this.optStateValues = res.data.rows
    })
  },
  methods: {
    getList() {
      this.listLoading = true;
      fetchProductDayList(this.listQuery).then(res => {
        this.dataList = res.data.rows;
        this.total = res.data.total;
        this.listLoading = false;
      })
    },
    reset() {
      this.listQuery.yxkjdate = '';
      this.listQuery.q_sellerId = "";
      this.getList();
    },
  }
}
</script>
